import { Root } from 'native-base';
import React from 'react';
import { ActivityIndicator, FlatList, Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
import { CheckBox } from 'react-native-elements';
// import { ScrollView } from 'react-native-gesture-handler';
export default function tpl(a: <T>(action: string, ...args: unknown[]) => ((...args: unknown[]) => void), s: (...class_names: string[]) => {}, d: (d: string) => string | unknown[]) {
	const dataArray = d('data') as Array<{ week: string; section: number; grade: string; class_name: string; data: { [key: string]: { grade_class_name: string } } }>;
	const ddd = d('chek');
	const grade_name = d('grade_name');
	const class_name = d('class_name');
	let c_t: boolean;
	let d_t: boolean;
	if (ddd === '1') {
		c_t = true;
		d_t = false;
	} else if (ddd === '2') {
		c_t = false;
		d_t = true;
	}
	if (dataArray) {

		return (
			<Root>
				<View>
					<ScrollView>
						<View style={{
							flexDirection: 'row'
						}}>
							{/* <TouchableOpacity > */}
							<View style={{ flex: 1 }}>
								<CheckBox title="个人课表" checked={c_t} onPress={a('a002')}>
								</CheckBox>
							</View>
							{/* </TouchableOpacity> */}
							{/* <TouchableOpacity > */}
							<View style={{ flex: 1 }}>
								<CheckBox title="班级课表" checked={d_t} onPress={a('a003')}></CheckBox>
							</View>
							{/* </TouchableOpacity> */}

						</View>
						{(() => {
							if (ddd === '2') {
								return (

									<View style={s('view1')}>
										<View style={s('view2')}>
											<TouchableOpacity onPress={a('a004')}>
												<Text style={s('text1')}>年级：</Text>
												<Text style={s('text2')}>{grade_name || '请选择'}</Text>
											</TouchableOpacity>
										</View>
										<View style={s('view2')}>
											<TouchableOpacity onPress={a('a005')}>
												<Text style={s('text1')}>班级：</Text>
												<Text style={s('text2')}>{class_name || '请选择'}</Text>
											</TouchableOpacity>
										</View>
									</View>

								);
							}
						})()}


						<View style={{ padding: 10 }}>
							<View style={s('view3')}>
								<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', borderRightColor: '#ddd', borderRightWidth: 1 }}>
									<Image source={require('../../imgs/kebiao.jpg')} style={{ width: 41, height: 50 }}></Image>
								</View>
								<View style={s('vborder1')}>
									<Text style={s('text')}>一</Text>
								</View>
								<View style={s('vborder1')}>
									<Text style={s('text3')}>二</Text>
								</View>
								<View style={s('vborder1')}>
									<Text style={s('text3')}>三</Text>
								</View>
								<View style={s('vborder1')}>
									<Text style={s('text3')}>四</Text>
								</View>
								<View style={s('vborder1')}>
									<Text style={s('text3')}>五</Text>
								</View>
								<View style={s('vborder1')}>
									<Text style={s('text3')}>六</Text>
								</View>
								<View style={s('vborder1')}>
									<Text style={s('text3')}>日</Text>
								</View>
							</View>
							{(() => {
								if (dataArray.length > 0) {
									return (
										<FlatList data={dataArray} renderItem={(item) => {
											return (
												<View style={s('view4')}>
													<View style={s('vborder1')}>
														<Text style={s('text4')}>{item.item.section}</Text>
													</View>
													<View style={s('vborder1')}>
														<Text style={s('text4')}>{item.item.data.星期一.grade_class_name || ''}</Text>
													</View>
													<View style={s('vborder1')}>
														<Text style={s('text4')}>{item.item.data.星期二.grade_class_name || ''}</Text>
													</View>
													<View style={s('vborder1')}>
														<Text style={s('text4')}>{item.item.data.星期三.grade_class_name || ''}</Text>
													</View>
													<View style={s('vborder1')}>
														<Text style={s('text4')}>{item.item.data.星期四.grade_class_name || ''}</Text>
													</View>
													<View style={s('vborder1')}>
														<Text style={s('text4')}>{item.item.data.星期五.grade_class_name || ''}</Text>
													</View>
													<View style={s('vborder1')}>
														<Text style={s('text4')}>{item.item.data.星期六.grade_class_name || ''}</Text>
													</View>
													<View style={s('vborder1')}>
														<Text style={s('text4')}>{item.item.data.星期日.grade_class_name || ''}</Text>
													</View>
												</View>
											);
										}} />
									);
								} else {
									return (
										<View style={s('page')}>
											<Image source={require('../../imgs/wushuju.png')} style={{ width: 80, height: 80 }} />
											<Text style={{ fontSize: 20 }}>没有符合当前筛选条件的数据</Text>
										</View>
									);
								}
							})()}


						</View>

					</ScrollView>
				</View>
			</Root>
		);
	} else {
		return (
			<View style={s('footer1')}>
				<ActivityIndicator />
				<Text>正在加载数据...</Text>
			</View>
		);
	}
}
